<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Template</title>
  </head>
  <body>
    <div></div>
    <script>
      const reg = /\{\{(.*?)\}\}/g;
      const div = document.querySelector('div');
      const template = `
      <h1>{{title}}</h1>
      <p>{{description}}</p>
    `;
      const data = {
        title: 'Hello World',
        description: 'This is a template',
      };
      const html = template.replace(reg, (match, key) => data[key]);
      div.innerHTML = html;
    </script>
  </body>
</html>
